package com.joysuch.wwyt.risk.service.impl;

import com.joysuch.wwyt.risk.entity.RiskEvaluationControl;
import com.joysuch.wwyt.risk.repository.RiskEvaluationControlDao;
import com.joysuch.wwyt.risk.service.RiskEvaluationControlService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author ZhaoQiuWei
 * @Date 2022/6/30 10:07
 */
@Service
@Slf4j
public class RiskEvaluationControlServiceImpl implements RiskEvaluationControlService {
    @Autowired
    private RiskEvaluationControlDao controlDao;

    @Override
    public boolean getStableEvalFlag() {
        boolean flag = false;
        RiskEvaluationControl stableControl = controlDao.findByName("区域固有风险评价");
        RiskEvaluationControl areaControl = controlDao.findByName("区域等级计算");
        if (stableControl != null && stableControl.getSwitchState().intValue() == 1 && areaControl != null && areaControl.getSwitchState().intValue() == 1) {
            flag = true;
        }
        return flag;
    }

    @Override
    public boolean getStableEvalFlagByCompany(String orgCode,Long tenentId) {
        boolean flag = false;
        RiskEvaluationControl stableControl = controlDao.findByNameAndCompany("区域固有风险评价",orgCode,tenentId);
        RiskEvaluationControl areaControl = controlDao.findByNameAndCompany("区域等级计算",orgCode,tenentId);
        if (stableControl != null && stableControl.getSwitchState().intValue() == 1 && areaControl != null && areaControl.getSwitchState().intValue() == 1) {
            flag = true;
        }
        return flag;
    }

    @Override
    public boolean getStableCorFlag() {
        boolean flag = false;
        RiskEvaluationControl stableControl = controlDao.findByName("区域固有风险评价");
        if (stableControl != null && stableControl.getSwitchState().intValue() == 0 ) {
            flag = true;
        }
        return flag;
    }

}
